package org.chen.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.chen.domain.entity.UserVideoConfig;
@Mapper
public interface UserVideoConfigMapper extends BaseMapper<UserVideoConfig> {

    /**
     * 更新除了指定ID外的所有配置为非默认
     */
    @Update("UPDATE user_video_config SET is_default = false WHERE id != #{id}")
    int updateOtherConfigsDefault(@Param("id") String id);


    default long countByAvatarId(String avatarId) {
        return selectCount(
                new QueryWrapper<UserVideoConfig>()
                        .eq("avatar_id", avatarId)
        );
    }
}
